/*     */ package com.yc.dao;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.UsedFiberMapBO;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class UsedFiberMapDAO
/*     */ {
/*  19 */   private static final Log log = LogFactory.getLog(UsedFiberMapDAO.class);
/*     */ 
/*  21 */   private dbConnector dbcon = null;
/*  22 */   private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/*     */ 
/*  24 */   private static Map countMap = new HashMap();
/*     */ 
/*     */   private void dbConInit() {
/*  27 */     if (this.dbcon == null)
/*  28 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   public void dbConClose() {
/*  32 */     if (this.dbcon != null)
/*  33 */       this.dbcon.closeAll();
/*  34 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getUsedFiberMapList(Map condition)
/*     */   {
/*  39 */     log.info(" query usedfibermap .");
/*  40 */     dbConInit();
/*  41 */     ListContentsBFO bfo = new ListContentsBFO();
/*  42 */     String ocid = condition.get("id").toString();
/*  43 */     int start = Integer.parseInt(condition.get("start").toString());
/*  44 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*     */ 
/*  46 */     ResultSet rs = null;
/*  47 */     List fileList = new ArrayList();
/*     */     try {
/*  49 */       String strSQL = "select count(id) from usedfibermap where ocid = '" + ocid + "'";
/*     */ 
/*  51 */       log.info(strSQL);
/*  52 */       rs = this.dbcon.execQuery(strSQL);
/*  53 */       if (rs.next()) {
/*  54 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  56 */       strSQL = "select * from usedfibermap where ocid = '" + ocid + "' limit " + start + ", " + limit;
/*     */ 
/*  58 */       log.info(strSQL);
/*  59 */       rs = this.dbcon.execQuery(strSQL);
/*  60 */       while (rs.next()) {
/*  61 */         UsedFiberMapBO bo = new UsedFiberMapBO();
/*  62 */         bo.setId(rs.getString("id"));
/*  63 */         bo.setOcid(rs.getString("ocid"));
/*  64 */         bo.setOcName(rs.getString("ocName"));
/*  65 */         bo.setA_netid(rs.getString("a_netid"));
/*  66 */         bo.setA_panelid(rs.getString("a_panelid"));
/*  67 */         bo.setA_fiber_id(rs.getString("a_fiber_id"));
/*  68 */         bo.setA_usedinfo(rs.getString("a_usedinfo"));
/*  69 */         bo.setB_netid(rs.getString("b_netid"));
/*  70 */         bo.setB_panelid(rs.getString("b_panelid"));
/*  71 */         bo.setB_fiber_id(rs.getString("b_fiber_id"));
/*  72 */         bo.setB_usedinfo(rs.getString("b_usedinfo"));
/*  73 */         bo.setA_station(rs.getString("a_station"));
/*  74 */         bo.setB_station(rs.getString("b_station"));
/*  75 */         bo.setDirection(rs.getString("direction"));
/*  76 */         fileList.add(bo);
/*     */       }
/*  78 */       bfo.setData(fileList.toArray());
/*     */     } catch (Exception e) {
/*  80 */       e.printStackTrace();
/*  81 */       log.error("query file failed .");
/*     */     } finally {
/*  83 */       dbConClose();
/*     */     }
/*  85 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean createUsedFiberMapBO(UsedFiberMapBO bo) {
/*  89 */     boolean flag = true;
/*     */     try {
/*  91 */       dbConInit();
/*  92 */       StringBuffer buf = new StringBuffer();
/*  93 */       buf.append("insert into usedfibermap ( ");
/*  94 */       buf.append(" ocid,ocName,a_netid,a_panelid,a_fiber_id, ");
/*  95 */       buf.append(" a_usedinfo,b_netid,b_panelid,b_fiber_id, ");
/*  96 */       buf.append(" b_usedinfo, a_station,b_station,direction ");
/*  97 */       buf.append(" ) values (  ");
/*  98 */       buf.append(" '" + bo.getOcid() + "',");
/*  99 */       buf.append(" '" + bo.getOcName() + "',");
/* 100 */       buf.append(" '" + bo.getA_netid() + "',");
/* 101 */       buf.append(" '" + bo.getA_panelid() + "',");
/* 102 */       buf.append(" '" + bo.getA_fiber_id() + "',");
/* 103 */       buf.append(" '" + bo.getA_usedinfo() + "',");
/* 104 */       buf.append(" '" + bo.getB_netid() + "',");
/* 105 */       buf.append(" '" + bo.getB_panelid() + "',");
/* 106 */       buf.append(" '" + bo.getB_fiber_id() + "',");
/* 107 */       buf.append(" '" + bo.getB_usedinfo() + "',");
/* 108 */       buf.append(" '" + bo.getA_station() + "',");
/* 109 */       buf.append(" '" + bo.getB_station() + "',");
/* 110 */       buf.append(" '" + bo.getDirection() + "' )");
/*     */ 
/* 112 */       log.info(buf.toString());
/* 113 */       this.dbcon.execUpdate(buf.toString());
/*     */     } catch (Exception e) {
/* 115 */       flag = false;
/* 116 */       e.printStackTrace();
/* 117 */       log.error(e.getMessage());
/* 118 */       log.error("save usedfibermap failure ");
/*     */     } finally {
/* 120 */       dbConClose();
/*     */     }
/* 122 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updateUsedFiberMapBO(UsedFiberMapBO bo) {
/* 126 */     boolean flag = true;
/*     */     try {
/* 128 */       dbConInit();
/* 129 */       StringBuffer buf = new StringBuffer();
/* 130 */       buf.append("update  usedfibermap set ");
/*     */ 
/* 133 */       buf.append(" a_netid = '" + bo.getA_netid() + "',");
/* 134 */       buf.append(" a_panelid = '" + bo.getA_panelid() + "',");
/* 135 */       buf.append(" a_fiber_id = '" + bo.getA_fiber_id() + "',");
/* 136 */       buf.append(" a_usedinfo = '" + bo.getA_usedinfo() + "',");
/* 137 */       buf.append(" b_netid = '" + bo.getB_netid() + "',");
/* 138 */       buf.append(" b_panelid = '" + bo.getB_panelid() + "',");
/* 139 */       buf.append(" b_fiber_id = '" + bo.getB_fiber_id() + "',");
/* 140 */       buf.append(" b_usedinfo = '" + bo.getB_usedinfo() + "',");
/* 141 */       buf.append(" a_station = '" + bo.getA_station() + "',");
/* 142 */       buf.append(" b_station = '" + bo.getB_station() + "',");
/* 143 */       buf.append(" direction = '" + bo.getDirection() + "' ");
/* 144 */       buf.append(" where id = '" + bo.getId() + "'");
/*     */ 
/* 146 */       log.info(buf.toString());
/* 147 */       this.dbcon.execUpdate(buf.toString());
/*     */     } catch (Exception e) {
/* 149 */       flag = false;
/* 150 */       e.printStackTrace();
/* 151 */       log.error(e.getMessage());
/* 152 */       log.error("save usedfibermap failure ");
/*     */     } finally {
/* 154 */       dbConClose();
/*     */     }
/* 156 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deleteUsedFiberMapBO(String id) {
/* 160 */     boolean flag = true;
/*     */     try {
/* 162 */       dbConInit();
/* 163 */       String strSQL = "delete from usedfibermap  where id = '" + id + "' ";
/* 164 */       log.info(strSQL);
/* 165 */       this.dbcon.execUpdate(strSQL);
/*     */     } catch (Exception e) {
/* 167 */       flag = false;
/* 168 */       e.printStackTrace();
/* 169 */       log.error(e.getMessage());
/* 170 */       log.error("delete UsedFiberMapBO failure ");
/*     */     } finally {
/* 172 */       dbConClose();
/*     */     }
/* 174 */     return flag;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.UsedFiberMapDAO
 * JD-Core Version:    0.6.2
 */